<?php
	session_start();
	require_once('../inc/fnc.php');
	require_once('../inc/conn.php');
	
	//Update cookies dbase entry
	$uid = $_COOKIE["uid"];
	$identifier = $_COOKIE["identifier"];
		
	$query = "UPDATE `remember` SET `flag` = 'Y' WHERE `userid` = {$uid} AND `identifier` =  '{$identifier}'";
	mysql_query($query);
	
	//Delete all cookies
	setcookie('uid', "", time()-60*60*24*30, "/");			//Cookie Expiration time set to 1 month before now
	setcookie('identifier', "", time()-60*60*24*30, "/");
	setcookie('token', "", time()-60*60*24*30, "/" );
					
	// Unset alll session variable
	unset($_SESSION['login']);
	unset($_SESSION['userId']);
	session_unset();
	session_destroy();

	
	// Redirecting to home page
	redirect_to(DOMAIN);
?>